<?php
/**
 * Created by PhpStorm.
 * User: spatra
 * Date: 14-11-6
 * Time: 下午4:46
 */

class Lesson extends Eloquent
{
    public function student()
    {
        return $this->belongsToMany('User', 'lesson_students', 'lesson_id', 'student_id');
    }

    public function teacher()
    {
        return $this->hasOne('User', 'id', 'teacher_id');
    }

    public function discussion()
    {
        return $this->hasMany('Lesson_Discussion');
    }

    public function resource()
    {
        return $this->hasMany('Lesson_Resource');
    }

    protected $table = 'lessons';

    protected $guarded = ['id'];
}